import { $axios } from '@/utils/axios.js';
import {transScdCard, transScdCardSub} from '../globalDeterm/globalDeterm';
import config from "@/config";

// 4. GRAPES高分辨率确定性预报模式检验模块

// 4.1 页面加载
export function pageLoadInfo() {
    return $axios.post('/grapes_region_determ/page_load_info');
}

// 4.2 绘图请求
export function drawingRequest(type, data) {
    switch (type) {
        case 'grid_analyze':
            return $axios.post('/grapes_region_determ/grid_analyze', data);
        case 'station_analyze':
            return $axios.post('/grapes_region_determ/station_analyze', data);
        default:
            return null
    }
}

// 4.4 综合评分卡
export function scdCard(data) {
    return $axios.post('/grapes_region_determ/scd_card', data).then(res => {
        // 进行预处理
        const data = res.data;
        const options = ['BIAS', 'RMSE', 'STD'];
        const levelLength = 8; // level
        const timeLength = 3; // time series
        res.data = transScdCard(data, options, levelLength, timeLength);
        return Promise.resolve(res);
    });
}

// 4.4 综合评分卡: 二级图表
export function scdCardSub(data) {
    // 克隆一个对象出来，避免影响原来的对象
    const newData = JSON.parse(JSON.stringify(data));
    newData.type = 'an';
    if (newData.area.indexOf('obs') > -1) {
        newData.type = 'obs';
    }
    delete newData.area;
    return $axios.post('/grapes_region_determ/scd_card_sub', newData).then(res => {
        transScdCardSub(res.data);
        return Promise.resolve(res);
    });
}

// 4.4 综合评分卡: 申请置信度数据
export function scdCardGetConfidence() {
    return $axios.post('/grapes_region_determ/scd_card/get_confidence');
}